package com.payment.ktb.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.activity.main1.PaymentActivity;
import com.payment.ktb.activity.main4.SettleQueryActivity;
import com.payment.ktb.constants.ConstantsPay;
import com.payment.ktb.utils.AlertDialogUtils;
import com.payment.ktb.utils.SharedPreferencesUtils;


/**
 * Created by syd on 2016/6/2.
 */
public class Fragment_main1_old extends BaseFragment implements View.OnClickListener{

    LinearLayout ll_main1_notes;
    TextView tv_main1_notes;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }



    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_main1_old,null);
        view.findViewById(R.id.iv_home_1).setOnClickListener(this);
        view.findViewById(R.id.iv_home_2).setOnClickListener(this);
        ll_main1_notes = (LinearLayout) view.findViewById(R.id.ll_main1_notes);
        ll_main1_notes.setOnClickListener(this);
        if (TextUtils.isEmpty(SharedPreferencesUtils.getString(ConstantsPay.noticeText))) {
            ll_main1_notes.setVisibility(View.GONE);
        } else {
            tv_main1_notes = (TextView) view.findViewById(R.id.tv_main1_notes);
            tv_main1_notes.setText(SharedPreferencesUtils.getString(ConstantsPay.noticeText));
            if (SharedPreferencesUtils.getString(ConstantsPay.noticetimes).equals("0")) {
                AlertDialogUtils.showAlertDialog(mContext,SharedPreferencesUtils.getString(ConstantsPay.noticeText));
                SharedPreferencesUtils.putString(ConstantsPay.noticetimes,"1");
            }
        }
        return view;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {


            //home1
            case R.id.iv_home_1:
                startActivity(PaymentActivity.class);
                break;


            //home2
            case R.id.iv_home_2:
                startActivity(SettleQueryActivity.class);
                break;




            //通告
            case R.id.ll_main1_notes:
                AlertDialogUtils.showAlertDialog(mContext,SharedPreferencesUtils.getString(ConstantsPay.noticeText));
                break;
        }
    }
}
